<!DOCTYPE html>
<html class="reftest-wait">
<title>View transitions: basic cross-document navigation in an iframe while the main frame has a same-document transition</title>
<link rel="help" href="https://drafts.csswg.org/css-view-transitions-2/">
<link rel="author" href="mailto:khushalsagar@chromium.org">
<link rel="match" href="root-element-transition-iframe-with-startVT-on-main-ref.html">
<script src="/common/reftest-wait.js"></script>
<script src="resources/common.js"></script>

<style>
  #inner {
    view-transition-name: inner
  }

  ::view-transition {
    background: lightpink;
  }
  ::view-transition-group(root) {
    animation-duration: 300s;
    opacity: 0;
  }

  ::view-transition-old(inner), ::view-transition-new(inner) {
    animation: unset;
  }
  ::view-transition-old(inner) {
    opacity: 0;
  }
  ::view-transition-new(inner) {
    opacity: 1;
  }
</style>

<iframe id="inner" src="resources/root-element-transition-iframe.html?blue"></iframe>
<script>
async function runTest() {
  let frame = document.getElementById("inner");

  await document.startViewTransition(() => {
    document.documentElement.style.background = "orange";
    frame.style.border = "1px solid black";
  }).ready;

  frame.contentWindow.postMessage("checkrendering");
  await waitForMessage("rendered");

  frame.src = "resources/root-element-transition-iframe.html?grey";
  await waitForMessage("transition");

  takeScreenshot();
}
onload = () => requestAnimationFrame(() => requestAnimationFrame(runTest));
</script>
</html>
